﻿
using System.Windows.Media;
using Redbrick.Silverlight.Common;

namespace Moria.Common.Model
{
	 public class CaveFloor : Drawable
	 {
		  #region Declarations

		  //private Monster _CreaturePtr = null;
		  //private InventoryItem _ItemPtr = null;
		  private FloorType _FloorType = FloorType.NullWall;
		  private bool _IsRoom = false;
		  private bool _FieldMark = false;
		  private bool _PermLight = false;
		  private bool _TempLight = false;

		  #endregion

		  #region Constructor

		  public CaveFloor(DungeonLevel owner)
		  {
				if (this.Cave == null) this.Cave = owner;
				this.CanReposition = false;
		  }

		  #endregion Constructor

		  #region Properties


		  public DungeonLevel Cave { get; private set; }

		  /// <summary>
		  /// was cptr
		  /// </summary>
		  public Monster CreaturePtr
		  {
				get { return this.Cave.MonsterAt(this.Y, this.X); }
		  }

		  /// <summary>
		  /// was tptr
		  /// </summary>
		  public InventoryItem ItemPtr
		  {
				get { return this.Cave.ItemAt(this.Y, this.X); }
		  }

		  /// <summary>
		  /// was fval
		  /// </summary>
		  public FloorType FloorType
		  {
				get { return this._FloorType; }
				set
				{
					 if (value == this._FloorType) return;
					 this._FloorType = value;
					 this.RaisePropertyChanged(() => this.FloorType);
				}
		  }

		  /// <summary>
		  /// was lr
		  /// </summary>
		  public bool IsRoom
		  {
				get { return this._IsRoom; }
				set
				{
					 if (value == this._IsRoom) return;
					 this._IsRoom = value;
					 this.RaisePropertyChanged(() => this.IsRoom);
				}
		  }

		  /// <summary>
		  /// was fm
		  /// </summary>
		  public bool FieldMark
		  {
				get { return this._FieldMark; }
				set
				{
					 if (value == this._FieldMark) return;
					 this._FieldMark = value;
					 this.RaisePropertyChanged(() => this.FieldMark);
				}
		  }

		  /// <summary>
		  /// was pl
		  /// </summary>
		  public bool PermLight
		  {
				get { return this._PermLight; }
				set
				{
					 if (value == this._PermLight) return;
					 this._PermLight = value;
					 this.RaisePropertyChanged(() => this.PermLight);
				}
		  }

		  /// <summary>
		  /// was tl
		  /// </summary>
		  public bool TempLight
		  {
				get { return this._TempLight; }
				set
				{
					 if (value == this._TempLight) return;
					 this._TempLight = value;
					 this.RaisePropertyChanged(() => this.TempLight);
				}
		  }

		  public bool IsBlockedFloor { get { return this.FloorType == FloorType.BlockedFloor; } }
		  public bool isLightFloor { get { return this.FloorType == Moria.FloorType.LightFloor; } }
		  public bool HasItem { get { return this.ItemPtr != null; } }
		  public bool HasCreature { get { return this.CreaturePtr != null; } }
		  public bool HasLight { get { return this.HasPermLight | this.HasTempLight | this.FieldMark; } }
		  public bool HasTempLight { get { return this.TempLight; } }
		  public bool HasPermLight { get { return this.PermLight; } }
	
		  #endregion Properties

		  #region Methods

		  public override string GetDescription()
		  {
				//TODO: account for light/dark/etc.
				return this.FloorType.Description();
		  }

		  #endregion Methods


	 }
}
